﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Microsoft.FamilyShow"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    x:Class="Microsoft.FamilyShow.PersonInfo"
    MinWidth="800" MinHeight="600" IsVisibleChanged="UserControl_IsVisibleChanged">
  <UserControl.Resources>
    <SolidColorBrush x:Key="DarkBrush" Color="#FF000000"/>

    <!-- Converter for displaying the the first name with an apostrophe. -->
    <local:FirstNamePossessiveFormConverter x:Key="FirstNamePossessiveFormConverter"/>

    <Style x:Key="formatTextStyle" TargetType="{x:Type Button}">
      <Setter Property="FontFamily" Value="Palatino Linotype"></Setter>
      <Setter Property="Width" Value="30"></Setter>
      <Setter Property="FontSize" Value ="14"></Setter>
      <Setter Property="CommandTarget" Value="{Binding ElementName=StoryRichTextBox}"></Setter>
      <Setter Property="Background" Value="{x:Null}"/>
      <Setter Property="Foreground" Value="{DynamicResource FontColor}"/>
      <Setter Property="BorderBrush" Value="{x:Null}"/>
      <Setter Property="BorderThickness" Value="0,0,0,0"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type Button}">
            <Grid>
              <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
            </Grid>
            <ControlTemplate.Triggers>
              <Trigger Property="IsFocused" Value="True"/>
              <Trigger Property="IsDefaulted" Value="True"/>
              <Trigger Property="IsMouseOver" Value="True"/>
              <Trigger Property="IsPressed" Value="True"/>
              <Trigger Property="IsEnabled" Value="False"/>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

    <Style x:Key="ToolBarButton" BasedOn="{x:Null}" TargetType="{x:Type Button}">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type Button}">
            <Grid>
              <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
            </Grid>
            <ControlTemplate.Triggers>
              <Trigger Property="IsFocused" Value="True"/>
              <Trigger Property="IsDefaulted" Value="True"/>
              <Trigger Property="IsMouseOver" Value="True"/>
              <Trigger Property="IsPressed" Value="True"/>
              <Trigger Property="IsEnabled" Value="False"/>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

  </UserControl.Resources>

  <Border Margin="10,0,10,10" Style="{DynamicResource BorderStyle}" Background="{DynamicResource DarkBrush}">
    <DockPanel x:Name="MainPanel">

      <!-- Header Panel-->
      <DockPanel Margin="10,0,10,0" DockPanel.Dock="Top" Height="30" x:Name="HeaderPanel">
        <!-- Star -->
        <Path StrokeThickness="1.500000" Stroke="#ffffffff" StrokeMiterLimit="1.000000" Fill="#ff3952a3" Data="F1 M 9.816406,1.694336 L 12.351074,6.830078 L 18.018066,7.654297 L 13.918457,11.654297 L 14.886230,17.299805 L 9.816406,14.630859 L 4.746094,17.299805 L 5.713867,11.654297 L 1.611328,7.654297 L 7.281250,6.830078 L 9.816406,1.694336 Z" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Center"/>

        <TextBlock x:Name="NameHeader" Text="{Binding Path=Name, Mode=Default, FallbackValue=Name}" Style="{DynamicResource HeaderStyle}" FontWeight="Bold" Margin="5,0,0,0" VerticalAlignment="Center"/>

        <Button Width="30" Content="_Back" Click="CloseButton_Click" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" DockPanel.Dock="Right" Height="15" x:Name="CloseButton" IsCancel="True" IsDefault="True" FontSize="10"/>
      </DockPanel>

      <Border CornerRadius="0,0,10,10" x:Name="BodyBorder" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,1,0,0" Background="#FF282828">
        <Grid DockPanel.Dock="Top" x:Name="BodyGrid">
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.48*"/>
            <ColumnDefinition Width="0.52*"/>
          </Grid.ColumnDefinitions>
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
          </Grid.RowDefinitions>

          <!-- Photos Info-->
          <Border x:Name="PhotoInfoBorder" Margin="10,10,5,5">
            <StackPanel>
              <DockPanel Margin="10,0,10,0" x:Name="PhotoButtonsDockPanel">
                <Button x:Name="SetPrimaryButton" Content="Set as _Primary" Click="SetPrimaryButton_Click" IsEnabled="True" IsCancel="False" Width="100" Height="15" FontSize="10"/>
                <Button HorizontalAlignment="Right" x:Name="RemovePhotoButton" Content="_Remove Photo" DockPanel.Dock="Right" Height="15" Click="RemovePhotoButton_Click" IsEnabled="True" Style="{DynamicResource RedButtonStyle}" Width="100" FontSize="10"/>
              </DockPanel>

              <Image x:Name="DisplayPhoto" Source="{Binding Path=Image.Path, Mode=Default}" Margin="10,10,10,10" Stretch="Uniform" MaxHeight="280" MinHeight="280"/>
              <TextBlock HorizontalAlignment="Left" MinWidth="100" x:Name="CaptionTextBlock" Margin="10,0,10,0" Foreground="{DynamicResource FontColor}" FontSize="11" FontStyle="Italic" TextTrimming="CharacterEllipsis"/>
              <StackPanel Orientation="Horizontal" x:Name="TagsStackPanel">
                <Label Content="Tags:" FontSize="10" VerticalAlignment="Stretch" Foreground="{DynamicResource GrayFontColor}" HorizontalAlignment="Stretch" Margin="5,0,0,0"/>
                <ListBox x:Name="TagsListBox" Background="{x:Null}" BorderBrush="{x:Null}" Style="{DynamicResource TagsListStyle}" ItemTemplate="{DynamicResource TagsItemTemplate}" FontSize="11" Margin="0,2,0,0" VerticalAlignment="Bottom" />
              </StackPanel>
            </StackPanel>
          </Border>

          <!-- Photos List Box-->
          <Border x:Name="PhotosBorder" Background="{DynamicResource DarkBrush}" Grid.Row="1" Margin="10,0,5,10" BorderThickness="1,1,1,1" Padding="10,5,10,5" BorderBrush="{DynamicResource BorderBrush}">
            <Grid>
              <TextBlock Text="Drop photos into this box" HorizontalAlignment="Right" Foreground="{DynamicResource GrayFontColor}" FontSize="10"/>
              <ListBox AllowDrop="True" x:Name="PhotosListBox" Background="{x:Null}" ItemsSource="{Binding Path=Photos, Mode=Default}" IsSynchronizedWithCurrentItem="True" Drop="PhotosListBox_Drop" Style="{DynamicResource PhotosListStyle}" ItemContainerStyle="{DynamicResource PhotosListItemStyle}" SelectionChanged="PhotosListBox_SelectionChanged" Margin="0,15,0,0"/>
            </Grid>
          </Border>

          <!-- Story View -->
          <Border x:Name="StoryViewBorder" Background="{DynamicResource PanelGradientBrush}" Grid.Column="1" Grid.RowSpan="2" Margin="5,10,10,10">
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition Height="40"/>
                <RowDefinition Height="*"/>
              </Grid.RowDefinitions>
              <DockPanel Margin="10,10,0,0">
                <TextBlock Text="{Binding Path=FirstName, Converter={StaticResource FirstNamePossessiveFormConverter}, Mode=Default, FallbackValue=Firstname}" TextWrapping="Wrap" Style="{DynamicResource HeaderStyle}" FontSize="18" FontWeight="Bold" Margin="5,0,0,0"/>
                <TextBlock Text="Story" TextWrapping="Wrap" Style="{DynamicResource HeaderStyle}" FontSize="18" FontWeight="Bold" Margin="0,0,0,0"/>
                <Button x:Name="EditStoryButton" Content="_Edit" Click="EditStoryButton_Click" HorizontalAlignment="Right" Margin="0,0,10,0" DockPanel.Dock="Right" VerticalAlignment="Top"/>
              </DockPanel>

              <FlowDocumentReader HorizontalAlignment="Stretch" x:Name="StoryViewer" VerticalAlignment="Stretch" Grid.Row="1" Margin="5,0,10,10" MinZoom="50" Zoom="80" IsFindEnabled="False" IsPrintEnabled="False" IsTwoPageViewEnabled="False" MaxZoom="150" Background="#00FFFFFF" Foreground="#FFFFFFFF">
                <!-- Sample Rich Text -->
                <FlowDocument FontFamily="Calibri" FontSize="12" LineHeight="14" TextAlignment="Left" Foreground="#FFFFFFFF">
                </FlowDocument>
              </FlowDocumentReader>
            </Grid>
          </Border>

          <!-- Story Edit -->
          <Border x:Name="StoryEditBorder" Background="{DynamicResource PanelGradientBrush}" Grid.Column="1" Grid.RowSpan="2" Margin="5,10,0,10" d:IsHidden="True">
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition Height="40"/>
                <RowDefinition Height="*"/>
              </Grid.RowDefinitions>
              <DockPanel Margin="10,10,0,0">
                <TextBlock Text="{Binding Path=FirstName, Converter={StaticResource FirstNamePossessiveFormConverter}, Mode=Default, FallbackValue=Firstname}" TextWrapping="Wrap" Style="{DynamicResource HeaderStyle}" FontSize="18" FontWeight="Bold" Margin="5,0,0,0"/>
                <TextBlock Text="Story" TextWrapping="Wrap" Style="{DynamicResource HeaderStyle}" FontSize="18" FontWeight="Bold" Margin="0,0,0,0"/>
                <Button HorizontalAlignment="Right" Margin="0,0,15,0" x:Name="CancelStoryButton" Content="_Cancel" DockPanel.Dock="Right" IsCancel="True" Click="CancelStoryButton_Click" VerticalAlignment="Top"/>
                <Button x:Name="SaveStoryButton" Content="_Save" HorizontalAlignment="Right" Margin="0,0,15,0" DockPanel.Dock="Right" IsDefault="True" Click="SaveStoryButton_Click" VerticalAlignment="Top" />
              </DockPanel>
              <DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" Margin="10,0,10,10">

                <!-- This tool bar contains all the editing buttons. -->
                <Border BorderBrush="{DynamicResource BorderBrush}" DockPanel.Dock="Top" Background="{DynamicResource LightBrush}" BorderThickness="1,1,1,0">
                  <StackPanel Name="mainToolBar" Height="30" Orientation="Horizontal">
                    <StackPanel.Background>
                      <LinearGradientBrush EndPoint="0.513,0.856" StartPoint="0.513,-0.218">
                        <GradientStop Color="#FF252D50" Offset="0.416"/>
                        <GradientStop Color="#FF4A5790" Offset="0.54"/>
                      </LinearGradientBrush>
                    </StackPanel.Background>
                    <Button Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleBold" ToolTip="Bold" Margin="0,0,0,0">
                      <TextBlock FontWeight="Bold">B</TextBlock>
                    </Button>
                    <Button Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleItalic" ToolTip="Italic" Margin="0,0,0,0">
                      <TextBlock FontStyle="Italic" FontWeight="Bold">I</TextBlock>
                    </Button>
                    <Button Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleUnderline" ToolTip="Underline" Margin="0,0,0,0">
                      <TextBlock TextDecorations="Underline" FontWeight="Bold">U</TextBlock>
                    </Button>
                  </StackPanel>
                </Border>

                <Border BorderBrush="{DynamicResource BorderBrush}" Background="{DynamicResource LightBrush}" BorderThickness="1,1,1,1">
                  <RichTextBox x:Name="StoryRichTextBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.RowSpan="1" AcceptsTab="True" FontSize="11" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#FF000000"/>
                </Border>
              </DockPanel>
            </Grid>
          </Border>

        </Grid>
      </Border>
    </DockPanel>
  </Border>
</UserControl>
